import axios from '@/libs/api.request'
import Qs from 'qs'
let prefix = '/sales/'
// const api = 'http://10.101.3.123:8891'
export const getDicQuery = data => {
  return axios.request({
    url: prefix + 'merchant/dict/query',
    method: 'post',
    data: data
  })
}
export const setDicSave = data => {
  return axios.request({
    url: prefix + 'merchant/dict/save',
    method: 'post',
    data: data
  })
}
export const getConfigItem = data => {
  return axios.request({
    url: prefix + 'merchant/config/item',
    method: 'post',
    data: data
  })
}

// 签赠设置
export const getQianzengQuery = data => {
  return axios.request({
    url: prefix + 'largess/authorizer_set/query',
    method: 'post',
    data: data
  })
}

export const setQianzengCreate = data => {
  return axios.request({
    url: prefix + 'largess/authorizer_set/create',
    method: 'post',
    data: data
  })
}

export const setQianzengDelete = data => {
  return axios.request({
    url: prefix + 'largess/authorizer_set/delete',
    method: 'post',
    data: data
  })
}

export const setQianzengUpdate = data => {
  return axios.request({
    url: prefix + 'largess/authorizer_set/update',
    method: 'post',
    data: data
  })
}
export const getQianzengRole = data => {
  // 获取角色
  return axios.request({
    url: '/oms/merchant/role/list',
    method: 'post',
    data: data
  })
}
// 收银点设置
export const getCashierList = data => {
  return axios.request({
    url: prefix + 'cashier/list',
    method: 'post',
    data: data
  })
}

export const getShopQuery = data => {
  // 查询shopCode和shopName
  return axios.request({
    url: prefix + 'shop/info/query',
    method: 'post',
    data: data
  })
}

export const getCashierSave = data => {
  // 添加收银点
  return axios.request({
    url: prefix + 'cashier/add',
    method: 'post',
    data: data
  })
}
export const bindCashier = data => {
  return axios.request({
    url: prefix + 'cashier/bind',
    method: 'post',
    data: data
  })
}
export const unbindCashier = data => {
  return axios.request({
    url: prefix + 'cashier/unbind',
    method: 'post',
    data: data
  })
}
export const unbindForceCashier = data => {
  return axios.request({
    url: prefix + 'cashier/force/unbind',
    method: 'post',
    data: data
  })
}
export const updateCashierQuery = data => {
  return axios.request({
    url: prefix + 'cashier/update',
    method: 'post',
    data: data
  })
}

export const getCashierDelete = data => {
  return axios.request({
    url: prefix + 'cashier/delete',
    method: 'post',
    data: data
  })
}
// 套餐管理
export const getSalesPackageList = data => {
  return axios.request({
    url: prefix + 'package/admin/list',
    method: 'post',
    data: data
  })
}
export const createSalesPackage = data => {
  return axios.request({
    url: prefix + 'package/save',
    method: 'post',
    data: data
  })
}
export const openSalesPackage = data => {
  return axios.request({
    url: prefix + 'package/status/update',
    method: 'post',
    data: data
  })
}
export const lookSalesPackage = data => {
  return axios.request({
    url: prefix + 'package/detail',
    method: 'post',
    data: data
  })
}
export const delSalesPackage = data => {
  return axios.request({
    url: prefix + 'package/del',
    method: 'post',
    data: data
  })
}
// 收款项
export const getbusinessItemQuery = data => {
  // 左边树结构Query
  return axios.request({
    url: prefix + 'merchant/bizitem/query',
    method: 'post',
    data: data
  })
}
export const getproductQuery = data => {
  // 点击父加载的子级别列表
  return axios.request({
    url: prefix + 'product/query',
    method: 'post',
    data: data
  })
}
export const setproductDelete = data => {
  return axios.request({
    url: prefix + 'product/delete',
    method: 'post',
    data: data
  })
}

export const setproductSave = data => {
  return axios.request({
    url: prefix + 'product/save',
    method: 'post',
    data: data
  })
}
export const setbizitemUpdate = data => {
  // 设置是否禁用
  return axios.request({
    url: prefix + 'merchant/bizitem/update',
    method: 'post',
    data: data
  })
}

// 水吧套餐
export const getSalesPackageList2 = data => {
  return axios.request({
    url: prefix + 'package/list',
    method: 'post',
    data: data
  })
}
export const getwaterBarPackageSave = data => {
  return axios.request({
    url: prefix + 'package/save',
    method: 'post',
    data: data
  })
}
export const getProductCategory = data => {
  return axios.request({
    url: prefix + 'product/category/list',
    method: 'post',
    data: data
  })
}
export const getProductAdd = data => {
  return axios.request({
    url: prefix + 'product/category/save',
    method: 'post',
    data: data
  })
}
export const getProductDel = data => {
  return axios.request({
    url: prefix + 'product/category/delete',
    method: 'post',
    data: data
  })
}
export const getProductQuery = data => {
  // 获取二级树水吧页面应用
  return axios.request({
    url: prefix + 'product/query',
    method: 'post',
    data: data
  })
}
export const setProductDel = data => {
  // 水吧的删除
  return axios.request({
    url: prefix + 'package/del',
    method: 'post',
    data: data
  })
}
export const setProductDetail = data => {
  // 水吧的查看详情
  return axios.request({
    url: prefix + 'package/detail',
    method: 'post',
    data: data
  })
}
// 礼品商品设置
export const getGiftShopList = data => {
  // 水吧的搜索
  return axios.request({
    url: prefix + 'product/list',
    // baseURL: 'http://10.101.3.230:8899/sales/product/list',
    method: 'post',
    data: data
  })
}
// 供应商名称获取
export const getSupplierNameList = data => {
  return axios.request({
    url: prefix + 'supplier/dropdownlist',
    // baseURL: 'http://10.101.3.230:8899/sales/supplier/dropdownlist',
    method: 'post',
    data: data
  })
}
export const creatGiftShop = data => {
  return axios.request({
    url: prefix + 'product/save',
    // baseURL: 'http://10.101.3.230:8899/sales/product/save',
    method: 'post',
    data: data
  })
}
export const lookGiftShopDetail = data => {
  return axios.request({
    url: prefix + 'product/query',
    method: 'post',
    data: data
  })
}
export const delGiftShop = data => {
  return axios.request({
    url: prefix + 'product/delete',
    // baseURL: 'http://10.101.3.230:8899/sales/product/delete',
    method: 'post',
    data: data
  })
}
export const lookShopInfo = data => {
  return axios.request({
    url: prefix + 'product/query',
    method: 'post',
    data: data
  })
}
export const shopDetailMessage = data => {
  return axios.request({
    url: prefix + 'shop/info/query',
    method: 'post',
    data: data
  })
}
// 门店管理
export const lookShopInfos = data => {
  return axios.request({
    url: prefix + 'shop/info/query',
    method: 'post',
    data: data
  })
}
export const updateShopInfos = data => {
  return axios.request({
    url: prefix + 'shop/update',
    method: 'post',
    data: data
  })
}
// 待机动画设置
export const getMaterialInfos = data => {
  return axios.request({
    url: prefix + 'merchant/material/query',
    method: 'post',
    data: data
  })
}
// 固件升级-物料列表
export const getMaterialList = data => {
  return axios.request({
    url: prefix + 'merchant/material/query',
    method: 'post',
    data: data
  })
}
// 固件升级-门店物料列表
export const shopMaterialList = data => {
  return axios.request({
    url: prefix + 'merchant/material/config/query',
    method: 'post',
    data: data
  })
}
// 历史记录
export const getHistoryList = data => {
  return axios.request({
    url: prefix + 'merchant/material/publish/record',
    method: 'post',
    data: data
  })
}
// 删除物料
export const delectMaterial = data => {
  return axios.request({
    url: prefix + 'merchant/material/delete',
    method: 'post',
    data: data
  })
}
export const saveMaterialInfos = data => {
  return axios.request({
    url: prefix + 'merchant/material/config/save',
    method: 'post',
    data: data
  })
}
export const getWholeMaterialInfos = data => {
  return axios.request({
    url: prefix + 'merchant/material/config/query',
    method: 'post',
    data: data
  })
}
// 上传物料
export const saveWholeMaterialInfos = data => {
  return axios.request({
    url: prefix + 'merchant/material/save',
    method: 'post',
    data: data
  })
}
export const deleteWholeMaterialInfos = data => {
  return axios.request({
    url: prefix + 'merchant/material/delete',
    method: 'post',
    data: data
  })
}
export const settingWholeMaterialInfos = data => {
  return axios.request({
    url: prefix + 'merchant/material/publish/record',
    method: 'post',
    data: data
  })
}
// 以下为刷卡器、待机动画、跑马灯及出票类型改造接口
export const iterationFirmwareList = (data) => { // 固件升级设置列表
  return axios.request({
    url: '/machine/config/shop/firmware/statistics',
    method: 'post',
    data: data
  })
}
// 查询供应商
export const supplierList = data => {
  return axios.request({
    url: prefix + 'supplier/list',
    // baseURL: 'http://10.101.3.66:8899/sales/supplier/list',
    method: 'post',
    data: data
  })
}
// 新增修改供应商
export const addSupplierList = data => {
  return axios.request({
    url: prefix + 'supplier/save',
    // baseURL: 'http://10.101.3.66:8899/sales/supplier/save',
    method: 'post',
    data: data
  })
}

export const iterationOutbillList = (data) => { // 出票类型设置列表
  return axios.request({
    url: '/machine/config/shop/lottery/statistics',
    method: 'post',
    data: data
  })
}
// 非直营供应商展示
export const getSupplierList = data => {
  return axios.request({
    url: prefix + 'supplier/get',
    // baseURL: 'http://10.101.3.66:8899/sales/supplier/get',
    method: 'post',
    data: data
  })
}

// 非直营供应商删除
export const deleteSupplierList = data => {
  return axios.request({
    url: prefix + 'supplier/delete',
    // baseURL: 'http://10.101.3.66:8899/sales/supplier/delete',
    method: 'post',
    data: data
  })
}
// 非直营店供应商状态开关
export const switchSupplierList = data => {
  return axios.request({
    url: prefix + 'supplier/status/update',
    method: 'post',
    data: data
  })
}
//  非直营店分类信息同步
export const udtSupplierList = data => {
  return axios.request({
    url: '/api/inventory/category/save',
    method: 'post',
    data: data
  })
}
// 非直营店分类信息删除
export const delSupplierList = data => {
  return axios.request({
    url: '/api/inventory/category/delete',
    method: 'post',
    data: data
  })
}
export const iterationAnimationList = (data) => { // 待机动画设置列表
  return axios.request({
    url: '/machine/config/shop/picture/statistics',
    method: 'post',
    data: data
  })
}
export const iterationMarqueeList = (data) => { // 跑马灯设置列表
  return axios.request({
    url: '/machine/config/shop/led/statistics',
    method: 'post',
    data: data
  })
}
export const iterationHistoryList = (data) => { // 门店及投币口历史记录
  return axios.request({
    url: '/machine/config/publish/history_list',
    method: 'post',
    data: data
  })
}
export const setSlitPort = (data) => { // 门店及投币口设置
  return axios.request({
    url: '/machine/config/slot/publish',
    method: 'post',
    data: data
  })
}
export const shopRestart = (data) => { // 门店重启
  return axios.request({
    url: '/machine/config/shop/restart',
    method: 'post',
    data: Qs.stringify(data),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}
export const slitRestart = (data) => { // 投币口重启
  return axios.request({
    url: '/machine/config/slot/restart',
    method: 'post',
    data: Qs.stringify(data),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}
export const machineInstanceList = (data) => { // 批量操作查询所有机台实例
  return axios.request({
    url: '/machine/instance/list_by_shop_id',
    method: 'post',
    data: Qs.stringify(data),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}
export const machineCategoryList = (data) => { // 批量操作查询所有机台分类
  return axios.request({
    url: '/machine/config/category_list',
    method: 'get',
    params: data
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // }
  })
}
export const slitFirmwareList = (data) => { // 固件升级-投币口列表
  return axios.request({
    url: '/machine/config/slot/firmware/list',
    method: 'post',
    data: data
  })
}
export const slitAnimationList = (data) => { // 待机动画-投币口列表
  return axios.request({
    url: '/machine/config/slot/picture/list',
    method: 'post',
    data: data
  })
}
export const slitOutbillList = (data) => { // 出票类型-投币口列表
  return axios.request({
    url: '/machine/config/slot/lottery/list',
    method: 'post',
    data: data
  })
}
export const slitMarqueeList = (data) => { // 跑马灯-投币口列表
  return axios.request({
    url: '/machine/config/slot/led/list',
    method: 'post',
    data: data
  })
}
export const loadFirmwarePackage = (data) => { // 新增固件包与回退包
  return axios.request({
    url: '/oms/merchant/device/firmware/save',
    method: 'post',
    data: data
  })
}
export const getFirmwareManageList = (data) => { // 查询固件管理列表
  return axios.request({
    url: '/oms/merchant/device/firmware/query',
    method: 'post',
    data: data
  })
}
export const delFirmwareSingle = (data) => { // 删除固件
  return axios.request({
    url: '/oms/merchant/device/firmware/delete',
    method: 'post',
    data: data
  })
}
export const lookTargetFirmware = (data) => { // 查询目标版本列表
  return axios.request({
    url: '/oms/merchant/device/firmware/targets',
    method: 'post',
    data: data
  })
}
export const lookAnimationList = (data) => { // 查询待机动画列表
  return axios.request({
    url: '/oms/merchant/device/image/query',
    method: 'post',
    data: data
  })
}
export const addSingleAnimation = (data) => { // 新增待机动画
  return axios.request({
    url: '/oms/merchant/device/image/save',
    method: 'post',
    data: data
  })
}
export const delSingleAnimation = (data) => { // 删除待机动画
  return axios.request({
    url: '/oms/merchant/device/image/delete',
    method: 'post',
    data: data
  })
}

export const getFirmwareStoreTree = (data) => { // 获取已绑定刷卡器的门店
  return axios.request({
    url: '/machine/config/shop/tree',
    method: 'post',
    data: data
  })
}

//  更新套餐排序
export const updateSortList = data => {
  return axios.request({
    url: '/sales/package/sort/update',
    method: 'post',
    data: data
  })
}
export const getBinMachine = (data) => { // 获取门店中已绑定的机台
  return axios.request({
    url: '/machine/config/machine_instance',
    method: 'post',
    data: data
  })
}

// 关联套餐列表
export const mealRelatedList = data => {
  return axios.request({
    url: prefix + 'gamecoupon/list',
    method: 'post',
    data: data
  })
}

//  小游戏保存
export const saveGameList = (data) => {
  return axios.request({
    url: '/wechat/point/game/save',
    method: 'post',
    data: data
  })
}

// 小游戏列表
export const getGameList = (data) => {
  return axios.request({
    url: '/wechat/point/game/list',
    method: 'post',
    data: data
  })
}

// 生成门店二维码
export const createQrcode = (data) => {
  return axios.request({
    url: '/sales/shop/create_qrcode',
    method: 'post',
    data: data
  })
}
// 获取查询注册或小游戏活动列表
export const activityGames = (data) => {
  return axios.request({
    url: '/marketing/activity/list',
    method: 'post',
    data: data
  })
}

// 查询svip已设置的优惠券
export const getSvipCouponSetting = data => axios.request({
  url: '/sales/svip/coupon/setup/list',
  method: 'post',
  data: data
})
// svip套餐详情查询
export const getSvipDetail = data => axios.request({
  url: '/sales/svip/package/query',
  method: 'post',
  data: data
})
